// 云函数入口文件
const cloud = require('wx-server-sdk')
const shortid = require('shortid');

cloud.init()

// 云函数入口函数
exports.main = async (event, context) => {
  if (event.num) {
    const codes = []
    for(let i=0; i< event.num; i++){
      codes.push(shortid.generate())
    }
    return { codes }
  } else {
    return shortid.generate()
  }
}